#include <iostream>
#include <vector>
#include <set>

using namespace std;

class Sudoku {
public:
    int numbers[9][9]{}; // 表示9✖9的单元格

    Sudoku() {
        for (auto &number : numbers) {
            for (int &j : number)
                j = 0;
        }
    }

    void setNumber(int col, int (&number)[9]) {
        for (int i = 0; i < 9; i++)
            numbers[col][i] = number[i];
    }

    bool checkAnswer() {
        for (auto &number : numbers) {
            set<int> s;
            for (int j : number) {
                s.insert(j);
            }
            if (s.size() < 9)
                return false;
        }

        for (int i = 0; i < 9; i++) {
            set<int> s;
            for (auto &number : numbers) {
                s.insert(number[i]);
            }
            if (s.size() < 9)
                return false;
        }

        for (int start = 0; start <= 6; start += 3) {
            for (int end = 0; end <= 6; end += 3) {
                set<int> s;
                for (int i = start; i < start + 3; i++) {
                    for (int j = end; j < end + 3; j++) {
                        s.insert(numbers[i][j]);
                    }
                }
                if (s.size() < 9)
                    return false;
            }
        }
        return true;
    }
};

int main(int argc, char const *argv[]) {
    vector<Sudoku> vec;
    vector<Sudoku>::iterator iter;

    int count;
    cin >> count;
    int id = 0;

    int numberList[9];

    for (int i = 0; i < count; i++) {
        vec.emplace_back();

        for (int j = 0; j < 9; j++) {
            for (int &k : numberList)
                cin >> k;
            vec[id].setNumber(j, numberList);
        }

        id++;
    }

    for (iter = vec.begin(); iter != vec.end(); ++iter) {
        if (iter->checkAnswer())
            cout << "Yeah!" << endl;
        else
            cout << "Oh,No!" << endl;
    }

    return 0;
}
